package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.User;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.Map;

/**
 * C端用户相关接口持久层
 *
 * @author Moozy 2025/4/17 1:19
 **/
@Mapper
public interface UserMapper {

    /**
     * 通过 openId 获取用户
     *
     * @param openId
     * @return
     */
    @Select("select * from user where openid = #{openId}")
    User getByOpenId(String openId);

    /**
     * 新增用户
     *
     * @param user
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into user (openid, create_time) values(#{openid}, #{createTime})")
    void insert(User user);

    /**
     * 通过 id 获取用户
     *
     * @param id
     * @return
     */
    @Select("select * from user where id = #{id}")
    User getById(Long id);

    Integer countByMap(Map map);
}
